package com.wc.alorithm_blue_bridge_history.simulation_match3.K;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2024/3/17 21:11
 * @description https://www.lanqiao.cn/problems/16570/learning/?problem_list_id=29&page=1
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int l = 0, r = 0;
        int res = 0;
        for (char c : s.toCharArray()) {
            if (c == 'L') l++;
            else r++;
            if (l == r) res++;
        }
        System.out.println(res);
    }
}
